package com.mdc.controller;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 *
 * @author Mordecai
 * @version 1.0.0
 * @blog https://gitee.com/mordeky/SpringBoot
 *
 */
@Controller // 默认情况下Controller存在于Spring容器中的名字为helloController
//@Controller("HelloController")
//@Controller(value="HelloController")
@Scope("prototype")
//@Scope("singleton")
@RequestMapping("/controller") // 根路径
public class HelloController {
    // http://localhost:8080/controller/hello1
    @RequestMapping("/hello1")
    public String getStr1(){ return "index"; }

    // http://localhost:8080/controller/hello2
    @ResponseBody
    @RequestMapping("/hello2")
    public String getStr2(){ return "index"; }

    // http://localhost:8080/controller/hello2
    //@ResponseBody // 注释掉这一句话将会导致错误
    @RequestMapping("/hello3")
    public String getStr3(){ return "Hello world!"; }
}